#include<bits/stdc++.h>
using namespace std;
 
int n(string a,string b,string c){
    int res=0;
    int d[3];
     
    d[0]=a[0]-'0';
    d[1]=b[0]-'0';
    d[2]=c[0]-'0';
     
    sort(d,d+3);
     
    if(a[1]==b[1]&&b[1]==c[1]&&d[0]+1==d[1]&&d[1]+1==d[2]){
        res+=60000;
        return res+d[2]*100+d[1]*10+d[0]; 
    }else if(d[0]+1==d[1]&&d[1]+1==d[2]){
        res+=50000;
        return res+d[2]*100+d[1]*10+d[0];
    }else if(d[0]==d[1]&&d[1]==d[2]){
        res+=40000;
        return res+d[2]*100+d[1]*10+d[0];
    }else if(a[1]==b[1]&&b[1]==c[1]){
        res+=30000;
        return res+d[2]*100;
    }else if(d[0]==d[1]||d[1]==d[2]){
        res+=20000;
        if(d[0]==d[1]){
            return res+d[0];
        }else{
            return res+d[1];
        }
    }else{
        return d[2];
    }
     
}
int main(){ 
    string s[6];
    while(cin>>s[0]>>s[1]>>s[2]>>s[3]>>s[4]>>s[5]){
        int a=n(s[0],s[1],s[2]);
        int b=n(s[3],s[4],s[5]);
        if(a==b){
            cout<<"tie\n";
        }else if(a>b){
            cout<<"zhangsan\n";
        }else{
            cout<<"lisi\n";
        }
    }
    return 0;
}
